// Wait until the runtime is available
function waitForRuntime() {
if (window.vm && window.vm.runtime) {
monitorProjectStop();
} else {
console.log("Waiting for TurboWarp runtime...");
setTimeout(waitForRuntime, 500);
}
}
function monitorProjectStop() {
const runtime = window.vm.runtime;
console.log("Runtime found — monitoring project activity...");
const checkInterval = setInterval(() => {
// Check if there are no threads running (project stopped)
const isRunning = runtime.threads && runtime.threads.length > 0;
if (!isRunning) {
clearInterval(checkInterval);
console.log("Project has stopped — attempting to close window...");
try {
window.close();
} catch (e) {
console.warn("Unable to close window automatically:", e);
}
}
}, 1000);
}
waitForRuntime();